package com.ssy.lingxi.settle.accounts.controller;


import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.dto.request.CorporateAccountConfigRequest;
import com.ssy.lingxi.dto.response.CorporateAccountConfigResponse;
import com.ssy.lingxi.settle.accounts.model.vo.request.CorporateAccountConfigUpdateVO;
import com.ssy.lingxi.settle.accounts.model.vo.request.GetMemberAccountConfigVO;
import com.ssy.lingxi.settle.accounts.model.vo.response.MemberAccountConfigVO;
import com.ssy.lingxi.settle.accounts.service.CorporateAccountConfigService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;


/**
 *@menu 结算能力-结算规则配置-对公账户配置
 * @author wrc
 * @date 2020/8/5
 */
@RestController
@RequestMapping("/settle/accounts")
public class CorporateAccountConfigController extends BaseController {


    @Resource
    CorporateAccountConfigService corporateAccountConfigService;


    /**
     * 结算能力-结算规则配置-对公账户配置
     * @author wrc
     * @date 2020/8/25
     */
    @GetMapping("/corporate/account/config")
    public Wrapper<CorporateAccountConfigResponse> corporateAccountConfig(@RequestParam("memberId") Long memberId, @RequestParam("memberRoleId") Long memberRoleId) {
        return corporateAccountConfigService.corporateAccountConfig(memberId, memberRoleId);
    }

    /**
     * 查询对公账户配置
     * @author 伍将
     * @date 2020/10/22
     **/
    @RequestMapping(value = "/corporate/account/getDetail", method = RequestMethod.GET)
    public Wrapper<CorporateAccountConfigResponse> getDetail(HttpServletRequest httpServletRequest) {
        return corporateAccountConfigService.getDetail(this.getSysUser(httpServletRequest));
    }

    /**
     * 结算能力 结算规则配置 对公账户修改
     * @author wrc
     * @date 2020/8/25
     */
    @PostMapping("/corporate/account/update")
    public Wrapper<Void> corporateAccountUpdate(@Valid @RequestBody CorporateAccountConfigRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return corporateAccountConfigService.corporateAccountUpdate(request, sysUser);
    }

    /**
     * 结算能力 结算规则配置 对公账户修改详情
     * @author 伍将
     * @date 2020/12/17
     **/
    @RequestMapping("/corporate/account/updateDetail")
    public Wrapper<Void> corporateAccountUpdateDetail(HttpServletRequest httpServletRequest, @RequestBody @Valid CorporateAccountConfigUpdateVO updateVO) {
        return corporateAccountConfigService.corporateAccountUpdateDetail(getSysUser(httpServletRequest), updateVO);
    }

    /**
     * 获取会员对公账户配置
     * @author 伍将
     * @date 2020/12/28
     **/
    @RequestMapping(value = "/getMemberAccountConfig", method = RequestMethod.GET)
    public Wrapper<MemberAccountConfigVO> getMemberAccountConfig(@Valid GetMemberAccountConfigVO getMemberAccountConfigVO) {
        return corporateAccountConfigService.getMemberAccountConfig(getMemberAccountConfigVO);
    }
}
